<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--商户管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/setgamcash.css"/>

    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/member/css/core1.css?v=3"/>

    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>


</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ol class="breadcrumb">
                <li>当前位置是&nbsp;:</li>

                <li><a href="javascript:history.back();">营销工具</a></li>
                <li><a href="javascript:history.back(-1)">活动营销</a></li>

                <li class="active" style="color: #02b87f;">社交立减金</li>
            </ol>
        </div>
        <div class="panel panel-default ng-scope mgl15 mgr15">
            <div class="panel-heading">
                社交立减金规则列表
            </div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <td>编号</td>
                        <td>活动ID</td>
                        <td>开始时间</td>
                        <td>结束时间</td>
                        <td>赠送卡券</td>
                        <td>创建时间</td>
                        <td class="text-center">投放渠道</td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        {volist name="list" id="vo"}
                        <td>{$vo['id']}</td>
                        <td>{$vo['activity_id']}</td>
                        <td>{$vo['begin_timestamp']|date="Y-m-d H:i",###}</td>
                        <td>{$vo['end_timestamp']|date="Y-m-d H:i",###}</td>
                        <td>{$vo['title']}</td>
                        <td>{if condition="$vo['activity_time'] neq ''"} {$vo['activity_time']|date="Y-m-d H:i",###}{/if}</td>

                        <td>小程序</td>

                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
            {$list->render()}
        </div>

        <div class="panel panel-default mgl15 mgr15">

            <form class="form-horizontal" action="" method="post"  id="creatcard">
                <input type="hidden" name="type" value="1">

                <div class="panel-body">
                    <div class="form-horizontal" data-label="appid"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">小程序Appid</label>
                            <div class="col-sm-10">
                                <input type="text" name="activity_tinyappid" class="form-control"  placeholder="请输入小程序Appid" id="activity_tinyappid">
                                <div class="help-block col-sm-12 col-xs-12">用户点击链接后可静默添加到列表的小程序appid；</div>
                            </div>
                            <div class="text-danger"></div>
                        </div>
                    </div>
                    <div class="form-horizontal" data-label="gift_num"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">裂变数量</label>
                            <div class="col-sm-10">
                                <input type="text" name="gift_num" class="form-control"  placeholder="请输入裂变数量" id="gift_num" onchange="fun(this,3,15)">
                                <div class="help-block col-sm-12 col-xs-12">单个礼包社交立减金数量（3-15个）</div>
                            </div>

                        </div>
                    </div>
                    <div class="form-group ">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label "><span class="text-danger">*</span> 选择要赠送的卡券</label>
                        <div class="col-xs-10 col-sm-10 col-md-10 form1" >
                            <div class="gift-record"id="sel1">
                                <select name="card_id"  class="form-control cardsel" id="card_id" onchange="cardlist(this);">
                                    <option value="">--请选择--</option>
                                    {volist name="cardlist" id="vo"}
                                    <option value="{$vo['card_id']}" >{$vo['title']}</option>
                                    {/volist}
                                </select>
                                <input type="hidden" id="mid" name="mid" value="">
                                <input type="hidden" id="title" name="title" value="">
                            </div>
                            <div class="help-block col-sm-12 col-xs-12">选择要投放设置的卡券</div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">
                            背景颜色：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span>
                        </label>
                        <div class="col-sm-9 col-xs-12">
                            <div class="cover" id="colors">
                                <input type="hidden" name="color" value="#63b359;" >
                                <ul class="color-list clearfix">
                                    <li class="selected" style="background-color:#63b359;" data-color="#63b359"></li>
                                    <li style="background-color:#2c9f67;" data-color="#2c9f67"></li>
                                    <li style="background-color:#509fc9;" data-color="#509fc9"></li>
                                    <li style="background-color:#5885cf;" data-color="#5885cf"></li>
                                    <li style="background-color:#9062c0;" data-color="#9062c0"></li>
                                    <li style="background-color:#d09a45;" data-color="#d09a45"></li>
                                    <li style="background-color:#e4b138;" data-color="#e4b138"></li>
                                    <li style="background-color:#ee903c;" data-color="#ee903c"></li>
                                    <li style="background-color:#f08500;" data-color="#f08500"></li>
                                    <li style="background-color:#a9d92d;" data-color="#a9d92d"></li>
                                    <li style="background-color:#dd6549;" data-color="#dd6549"></li>
                                    <li style="background-color:#cc463d;" data-color="#cc463d"></li>
                                    <li style="background-color:#cf3e36;" data-color="#cf3e36"></li>
                                    <li style="background-color:#5E6671" data-color="#5E6671"></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal" data-label="开始时间"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">开始时间</label>
                            <div class="col-sm-10">
                                <input type="text" name="times" class="form-control" value="" placeholder="请选择开始时间" readonly="readonly" id="starttime">
                                <input type="hidden"  value=""  id="begin_timestamp">
                                <input type="hidden"  value=""  id="end_timestamp">
                                <input type="hidden" id="useEndTime">

                                <div class="help-block col-sm-12 col-xs-12">结束时间必须小于选择卡券结束时间。</div>
                            </div>
                        </div>
                    </div>

                    <div class="form-horizontal" data-label="max_partic_times_one_day"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">每日限领(选填)</label>
                            <div class="col-sm-10">
                                <input type="text" name="max_partic_times_one_day" class="form-control" value="1" placeholder="请输入每日限领" id="max_partic_times_one_day">
                                <div class="help-block col-sm-12 col-xs-12">每个用户活动期间单日最大领取次数,最大为50，不填默认为1</div>
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal" data-label="max_partic_times_act"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最多可领(选填)</label>
                            <div class="col-sm-10">
                                <input type="text" name="max_partic_times_act" class="form-control" value="1" placeholder="请输入每人最多可领次数" id="max_partic_times_act">
                                <div class="help-block col-sm-12 col-xs-12">每个用户活动期间最大领取次数,最大为50，不填默认为1</div>
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal" data-label="mch_code"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商户号</label>
                            <div class="col-sm-10">
                                <input type="text" name="mch_code" class="form-control"  placeholder="请输入商户号" id="mch_code">
                                <div class="help-block col-sm-12 col-xs-12">支付商户号</div>
                            </div>
                        </div>
                    </div>
                    <div class="form-horizontal" data-label="min_amt"
                         data-layout="horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">使用门槛</label>
                            <div class="col-sm-10">
                                <input type="text" name="min_amt" class="form-control"  placeholder="请输入使用门槛" id="min_amt" value="">
                                <div class="help-block col-sm-12 col-xs-12">最少支付金额，单位是元</div>
                            </div>
                        </div>
                    </div>

                    <!--<div class="form-group">-->
                        <!--<label class="col-sm-2 control-label ng-binding">状态：</label>-->
                        <!--<div class="col-sm-10">-->
                            <!--<select name="statu" id="" class="form-control">-->
                                <!--&lt;!&ndash;<option value="">&#45;&#45;请选择&#45;&#45;</option>&ndash;&gt;-->
                                <!--<option value="1">开启</option>-->
                                <!--<option value="2">关闭</option>-->
                            <!--</select>-->
                            <!--<div class="r-message text-danger ng-scope ng-inactive"></div>-->
                        <!--</div>-->
                    <!--</div>-->

                </div>
                <div class="panel-footer">
                    <button class="btn btn-success" type="submit" >保存</button>
                </div>
            </form>

        </div>
        {include file='public/footer'/}
    </div>
</section>
<script>

</script>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script>
    function cardlist(obj){
        var card_id=$(obj).val();
       // console.log(card_id);
        $.ajax({
                url:"{:url('marke/getcardsinfo')}",
                type:"post",
                data:{
                    card_id:card_id
                },
            success:function(data){
             if(data.code=='0'){

                $("#mch_code").val(data.mch_id);
                 $("#mid").val(data.mid);
                 $("#title").val(data.title);
                 $("#starttime").val(data.begin_timestamp+" - "+data.end_timestamp);
                 $("#end_timestamp").val(data.end_timestamp);
                 $("#begin_timestamp").val(data.begin_timestamp);


             }
              //  console.log(data);
            }
            });
        //console.log(card_id);
    }
</script>
<script>
    $(function () {
//        选取优惠券背景颜色
        $(".color-list li").click(function () {
            $(".color-list li").removeClass("selected");
            $(this).addClass("selected");
            var colors = $(this).attr("data-color");
            $(".card_section").css("background-color", colors);
            $(".ljsy").css("background-color", colors);
            $("input[name='color']").val(colors);
        });
    })
</script>
<script type="text/javascript">
    function fun(o,min,max){
        var value=o.value;
        var min=min;
        var max=max;

        if((/^(\+|-)?\d+$/.test( value ))&&value>0){


        }else{
            layer.alert("裂变数量中请输入正整数！");
            o.value='';


        }

        if(parseInt(value)<min||parseInt(value)>max){
            layer.alert('裂变数量最小3个最多15个！');
            o.value='';
        }

    }
</script>
<script>


    var date = new Date();
    var year = parseInt(date.getFullYear());
    var month = parseInt(date.getMonth())+1;
    var day = parseInt(date.getDate());
    var H = parseInt(date.getHours())+2;
    var M =parseInt( date.getMinutes());
    var S = parseInt(date.getSeconds());
    if(month<10){
        month = "0"+month;
    }
    if(day<10){
        day = "0"+day;
    }
    var min = year+"-"+month+"-"+day +" "+ H +':'+ M +':'+S;
    laydate.render({
        elem: '#starttime',
        type: 'datetime',
        range:'-',
        min:min,
        change: function(value, date,endDate){ //监听日期被切换
            console.log(value,endDate);
            if(endDate.month<10){
                endDate.month = "0"+endDate.month;
            }
            if(endDate.date<10){
                endDate.date = "0"+endDate.date;
            }
            if(endDate.hours<10){
                endDate.hours = "0"+endDate.hours;
            }
            if(endDate.minutes<10){
                endDate.minutes = "0"+endDate.minutes;
            }
            if(endDate.seconds<10){
                endDate.seconds = "0"+endDate.seconds;
            }
            var edate=endDate.year+"-"+endDate.month+"-"+endDate.date +" "+ endDate.hours +':'+endDate.minutes+':'+endDate.seconds;

            var end_timestamp = $("#end_timestamp").val();
            console.log(end_timestamp,edate);
//转换时间
            var start=new Date(end_timestamp.replace("-", "/").replace("-", "/"));
            var end=new Date(edate.replace("-", "/").replace("-", "/"));
//比较时间
            console.log(start,end);
            if(end > start){
                layer.alert("结束时间不可以大于卡券结束时间");
                $("#starttime").val("");
            }
        }
    });

//     // var date = new Date();
//     // //执行一个laydate实例
//     // laydate.render({
//     //     elem: '#starttime'
//     //     ,type: 'datetime'
//     //     ,range: true
//     //     ,min:data
//     // });
//
//
//
//         var laydate = laydate;
//         var date = new Date();
//         var year = parseInt(date.getFullYear());
//         var month = parseInt(date.getMonth())+1;
//         var day = parseInt(date.getDate());
//         var H = parseInt(date.getHours());
//         var M =parseInt( date.getMinutes());
//         var S = parseInt(date.getSeconds());
//     if(month<10){
//             month = "0"+month;
//         }
//         if(day<10){
//             day = "0"+day;
//         }
//         var min = year+"-"+month+"-"+day +" "+ H +':'+ M +':'+S;
//         console.log(min);
//
//
//  console.log(min);
//         var date = {
//             type: 'datetime',
//             min:min,
//             range:'-',
//             trigger: 'click'
//         };
//         date.elem = '#starttime';
// //执行一个laydate
//         laydate.render(date);

</script>
<script>

    function delsel(obj){
//
        $(obj).parent().remove();


    }

</script>
<script>
    /**验证*/

    $("#creatcard").submit(function(){


        var activity_tinyappid=$("#activity_tinyappid").val();
        var gift_num=$("#gift_num").val();
        var card_id=$("#card_id").val();
        var starttime=$("#starttime").val();
        var mch_code=$("#mch_code").val();
        var min_amt=Number($("#min_amt").val());


        if(activity_tinyappid==""){
            layer.alert("请填写小程序Appid！");
            return false;
        }
        if(gift_num==""){
            layer.alert("请填写裂变数量！");
            return false;
        }
        if(card_id==""){
            layer.alert("请选择要赠送的卡券！");
            return false;
        }
        if(starttime==""){
            layer.alert("请填写开始时间！");
            return false;
        }
        if(mch_code==""){
            layer.alert("请填写商户号！");
            return false;
        }
        if(min_amt==""){
            layer.alert("请填写使用门槛！");
            return false;
        }
        if(min_amt<0.01||min_amt>9999){
            layer.alert("使用门槛最小值0.01元，最大值9999！");
            return false;
        }
        return true;
    });
</script>
</body>

</html>
